//
//  SafeThreePeopleCell2.m
//  Estate
//
//  Created by wangdongdong on 2017/10/9.
//  Copyright © 2017年 ttsx. All rights reserved.
//

#import "SafeThreePeopleCell2.h"

@implementation SafeThreePeopleCell2


- (void)awakeFromNib {
    [super awakeFromNib];

    // 项目实际人数
    self.actualPeopleNumberLabel.textColor = mainTitleColor;
    self.actualPeopleNumberField.delegate = self;
    self.actualPeopleNumberField.tag = 1000;
    [self.actualPeopleNumberField addTarget:self action:@selector(textField1TextChange:) forControlEvents:UIControlEventEditingChanged];
    
    // 符合人数
    self.complyNumberLabel.textColor = mainTitleColor;
    self.complyNumberField.delegate = self;
    self.complyNumberField.tag = 2000;
    [self.complyNumberField addTarget:self action:@selector(textField1TextChange:) forControlEvents:UIControlEventEditingChanged];
    
    // 符合率
    self.coincidenceRateLabel.textColor = mainTitleColor;
    self.coincidenceRateLabel2.textColor = mainTitleColor;
    
    // 配备符合要求
    self.meetRequireLabel.textColor = mainTitleColor;
    [self.meetRequireSwitch addTarget:self action:@selector(meetRequire:) forControlEvents:UIControlEventValueChanged];
}

// 不可编辑
- (void)isNoEdit {
    self.actualPeopleNumberField.enabled = NO;
    self.complyNumberField.enabled = NO;
    self.meetRequireSwitch.enabled = NO;
}

#pragma mark UITextFieldDelegate(项目实际人数/符合人数)
- (void)textField1TextChange:(UITextField *)textField {
    
    if (textField.tag == 1000) {
        if (self.actualPeopleNumberBlock) {
            self.actualPeopleNumberBlock(textField.text);
        }
    } else if (textField.tag == 2000) {
        if (self.complyNumberBlock) {
            self.complyNumberBlock(textField.text);
        }
    }
}

// 配备符合要求
- (void)meetRequire:(UISwitch *)switchButton {
    BOOL isButtonOn = [switchButton isOn];
    if (isButtonOn) {
        
        if (self.meetRequireBlock) {
            self.meetRequireBlock(@"1");
        }
    } else {
        if (self.meetRequireBlock) {
            self.meetRequireBlock(@"0");
        }
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


@end

